﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;

namespace yarpagMobile {
	/// <summary>
	/// Yet Another Random PAssword Generator.
	/// Copyright (C) 2009  Torben K. Jensen
	/// 
	/// This program is free software: you can redistribute it and/or modify
	/// it under the terms of the GNU General Public License as published by
	/// the Free Software Foundation, either version 3 of the License, or
	/// (at your option) any later version.
	/// 
	/// This program is distributed in the hope that it will be useful,
	/// but WITHOUT ANY WARRANTY; without even the implied warranty of
	/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	/// GNU General Public License for more details.
	/// 
	/// You should have received a copy of the GNU General Public License
	/// along with this program.  If not, see http://www.gnu.org/licenses/.
	/// </summary>
	public class Settings {

		public const string Letters = "abcdefghijklmnopqrstuvwxyz";
		public const string Capitals = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		public const string chkNumbersStart = "Numbers ";
		public const string Numerals = "0123456789";
		public const string NumeralsName = "0-9";
		public const string SafeNumerals = "23456789";
		public const string SafeNumeralsName = "2-9";
		public const string ZeroName = "zero";
		public const string InfinityName = "an unfathomable number (more than I care to compute) of";
		public const string PowerFormat = " (ten to the power of {0:D})";
		public const string NumberFormat = "{0,3:F} ";
		public const string SmallNumberFormat = "###,###";
		public const string txtPasswordTooltipFormat = "This password is one of {0} possible combinations.";
		public const string lblPasswordCharCountFormat = "{0,3:D} Characters";
		public const string lblStatusStart = "Clipboard: ";
		public const string lblPasswordCharCountTooltip = "The number of password characters generated.";
		public const string chkSpecificText = "Specific: ";
		public const string chkSpecificTooltip = "Specify a specific set of special characters to allow.";
		public const string chkSpecialCharsText = "Special Characters";
		public const string chkSpecialCharsTooltip = "Allow passwords to contain other special characters.\r\nDefault is a universal set found in most keyboard layouts.";
		public const string chkSpacesText = "Spaces";
		public const string chkSpacesTooltip = "Allow passwords to contain spaces.";
		public const string chkUppercaseText = "Uppercase";
		public const string chkUppercaseTooltip = "Allow passwords to contain uppercase characters.";
		public const string chkNumbersTooltip = "Allow passwords to contain numerals, including or excluding zero and one.";
		public const string trkLengthTooltip = "Move slider to change password length.";
		public const string btnGenerateText = "Generate";
		public const string btnGenerateTooltip = "Generate a different password.";
		public const string btnCopyText = "Copy";
		public const string btnCopyTooltip = "Copy current password to clipboard.";
		public const string btnGenerateCopyText = "+";
		public const string btnGenerateCopyTooltip = "Generate a new password and copy it to clipboard.";
		public const string cboSpecificTooltip = "Select the special character set to allow.";
		public const string Whitespace = "\" \"";
		public const string txtPasswordText = "password";
		public const string LengthTestString = "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
		public const string txtPasswordFont = "Courier New, 8.25pt";
		public const string NegativePrefix = "minus ";

		public string cboSpecificText;
		public string chkNumbersText;
		public Point Location;
		public Point btnGenerateLocation;
		public Point btnCopyLocation;
		public Point btnGenerateCopyLocation;
		public Size Size;
		public Size trkLengthSize;
		public Size txtPasswordSize;
		public Size cboSpecificSize;
		public bool cboSpecificEnabled;
		public bool chkSpecificEnabled;
		public int PasswordLength;
		public CheckState chkUppercaseCheckState;
		public CheckState chkNumbersCheckState;
		public CheckState chkSpacesCheckState;
		public CheckState chkSpecialCharsCheckState;
		public CheckState chkSpecificCheckState;

		private string[] defaultNumberNames = new string[] {
			"thousand",
  		"million",
  		"billion",
  		"trillion",
  		"quadrillion",
  		"quintillion",
  		"sextillion",
  		"septillion",
  		"octillion",
  		"nonillion",
  		"decillion",
  		"undecillion",
  		"duodecillion",
  		"tredecillion",
  		"quattuordecillion",
  		"quindecillion",
  		"sexdecillion",
  		"septendecillion",
  		"octodecillion",
  		"novemdecillion",
  		"vigintillion"
		};


		private string[] defaultKeyboards = new string[] {
			"Universal", 
			"CZ", 
			"DA", 
			"DE", 
			"HU", 
			"US"
		};

		private string[] defaultSpecialChars = new string[] {
			"!?.,:;_-+=*/\"'%()", 
			"˚;+ĚěŠšČčŘřŽžÝýÁáÍíÉé%=ˇ´'\"/Úú()¨Ůů!§?,:._-*+", 
			"§½!\"@#£¤$%&/{([)]=}?+`´|€åÅ^¨~æÆøØ*'<>\\μ;,:._-", 
			"°^!\"²§³$%&/{([)]=}?ß\\`´@€Üü*+~ÖöÄä'#<>|μ;,:._-", 
			"§'\"+!%/=()ÖöÜüÓó\\|€Őő÷Úú×[]Éé$ÁáŰűÍí<>#&@{}?,;:._-*", 
			"`~!@#$%^&*()-_=+[{]}\\|;:'\",<>/?" 
		};

		private Point defaultLocation = new Point(0, 26);
		private Point defaultBtnCopyLocation = new Point(150, 120);
		private Point defaultBtnGenerateLocation = new Point(150,98);
		private Point defaultBtnGenerateCopyLocation = new Point(216, 98);
		private Size defaultSize = new Size(240, 294);
		private Size defaultTrkLengthSize = new Size(245, 45);
		private Size defaultTxtPasswordSize = new Size(227, 20);
		private Size defaultCboSpecificSize = new Size(117, 22);
		private int defaultPasswordLength = 8;

		private List<String> keyboards;
		private List<String> specialCharacters;
		private List<String> numberNames;
		#region Constructors and Destructors
		
		public Settings() {

			keyboards = new List<String>(defaultKeyboards);
			specialCharacters = new List<String>(defaultSpecialChars);
			numberNames = new List<String>(defaultNumberNames);
			Load();
		}

		#endregion .Constructors and Destructors

		#region Public Properties

		public List<String> Keyboards {

			get {
				return keyboards;
			}
		}

		public List<String> KeyboardSpecialCharacters {

			get {
				return specialCharacters;
			}
		}

		public List<String> NumberNames {

			get {
				return numberNames;
			}
		}

		#endregion .Public Properties

		#region Public Methods

		public void Load() {

			Location = defaultLocation;
			Size = defaultSize;
			btnGenerateLocation = defaultBtnGenerateLocation;
			btnCopyLocation = defaultBtnCopyLocation;
			btnGenerateCopyLocation = defaultBtnGenerateCopyLocation;
			trkLengthSize = defaultTrkLengthSize;
			txtPasswordSize = defaultTxtPasswordSize;
			cboSpecificSize = defaultCboSpecificSize;
			PasswordLength = defaultPasswordLength;
			cboSpecificText = keyboards[0];
			chkUppercaseCheckState = CheckState.Checked;
			chkNumbersCheckState = CheckState.Indeterminate;
			chkSpacesCheckState = CheckState.Unchecked;
			chkSpecialCharsCheckState = CheckState.Unchecked;
			chkSpecificCheckState = CheckState.Unchecked;
			chkSpecificEnabled = (chkSpecialCharsCheckState == CheckState.Checked);
			cboSpecificEnabled = (chkSpecificCheckState == CheckState.Checked);
			if (chkNumbersCheckState == CheckState.Checked)
				chkNumbersText = String.Format("{0} {1}", chkNumbersStart, Numerals);
			else if (chkNumbersCheckState == CheckState.Indeterminate)
				chkNumbersText = String.Format("{0} {1}", chkNumbersStart, SafeNumerals);
		}

		public void Save() {
			// Not yet implemented.
		}

		#endregion .Public Methods
	}
}
